﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;

namespace CoolCode.Tests.Data.Entity
{
    public class EntityTest
    {  
        public EntityTest()
        {
            DataContext.Context.Setup(typeof(Entities));
        }

        [Fact]
        public void QueryTest()
        { 
            var resp = new Respository<Customers>();
            var query = resp.Query(c => c.ContactName.Contains("e"));
            var list = query.ToList();
            Assert.Equal(true, list.Count > 0);
        }

        [Fact]
        public void InsertTest()
        { 
            Respository<Customers> resp = new Respository<Customers>();
            resp.Insert(new Customers
            {
                CustomerID = "Bruc6",
                CompanyName = "Cool Code"
            });

            var query = resp.Query(c => c.CustomerID .Contains("Bruc"));
            var list = query.ToList();
            Assert.Equal(true, list.Count >0);
            resp.Submit();
            query = resp.Query(c => c.CustomerID.Contains("Bruc"));
            list = query.ToList();
            Assert.Equal(true, list.Count >=3);

        }


    }
}
